<!DOCTYPE html>
<html lang="zh-CN" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>小风考试登录</title>
    <!-- Bootstrap -->
    <link href="/common/bootstrap/css/bootstrap.min.css" rel="stylesheet">
    <link href="/custom/css/admin-style.css" rel="stylesheet">
    <link href="/custom/css/style.css" rel="stylesheet">

    <!-- HTML5 shim 和 Respond.js 是为了让 IE8 支持 HTML5 元素和媒体查询（media queries）功能 -->
    <!-- 警告：通过 file:// 协议（就是直接将 html 页面拖拽到浏览器中）访问页面时 Respond.js 不起作用 -->
    <!--[if lt IE 9]>
    <script src="/common/bootstrap/js/html5shiv.min.js"></script>
    <script src="/common/bootstrap/js/respond.min.js"></script>
    <![endif]-->
</head>
<body>
<div id="particles-js" class="center-box">
    <div class="main">
        <h1 class="title text-primary">小风考试登录</h1>
        <form id="form">
            <input type="hidden" name="password" id="pwd">
            <div class="form-group">
                <div class="input-group">
                    <span class="input-group-addon">
                        <span class="glyphicon glyphicon-user text-primary" aria-hidden="true"></span>
                    </span>
                    <input type="text" class="form-control" placeholder="账号" name="loginName" id="loginName"
                           autocomplete="off">
                </div>
            </div>
            <div class="form-group">
                <div class="input-group">
                    <span class="input-group-addon">
                        <span class="glyphicon glyphicon-lock text-primary" aria-hidden="true"></span>
                    </span>
                    <input type="password" class="form-control" placeholder="密码" id="password">
                </div>
            </div>
            <div class="form-group">
                <button type="button" class="btn btn-primary btn-block" id="loginBtn">登录</button>
            </div>
            <div class="text-right">
                <a href="/admin/register">新用户注册&nbsp;<span class="glyphicon glyphicon-arrow-right" aria-hidden="true"></span></a>
            </div>
        </form>
    </div>
</div>

<!-- jQuery (Bootstrap 的所有 JavaScript 插件都依赖 jQuery，所以必须放在前边) -->
<script src="/common/bootstrap/js/jquery.min.js"></script>
<!-- 加载 Bootstrap 的所有 JavaScript 插件。你也可以根据需要只加载单个插件。 -->
<script src="/common/bootstrap/js/bootstrap.min.js"></script>
<script src="/common/layer/layer.js"></script>
<script src="/common/md5.js"></script>
<script src="/custom/js/common.js"></script>
<script src="/common/particles/particles.min.js"></script>
<script src="/common/particles/app.js"></script>
<script>
    //登录
    $(document).on("click", "#loginBtn", function () {
        var loginName = $("#loginName").val();
        if (loginName === '') {
            msgAlert("请输入账号");
            return;
        }
        var password = $("#password").val();
        if (password === '') {
            msgAlert("请输入密码");
            return;
        }
        $("#pwd").val(hex_md5(password + KEY));
        ajaxJson("/ajax/login", $("#form").serialize(), function (res) {
            if (res.status) {
                if (res.data.type==="A"){
                    location.href = "/admin/user/list";
                }else{
                    location.href = "/web/user/exam/list";
                }
            } else {
                if (res.code === -1) {
                    msgAlert("账号或密码不正确");
                }else{
                    msgAlert(res.message);
                }
            }
        })
    });
</script>
</body>
</html>